package com.itboye.mengwu.data.presenter;

import java.util.List;
import java.util.Observer;

import android.util.Log;

import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.object.BasePresenter;
import com.itboye.core.object.ResultEntity;
import com.itboye.mengwu.app.ui.main.MainPresenter;
import com.itboye.mengwu.data.interfaces.IRedBag;
import com.itboye.mengwu.data.interfaces.IShopCar;
import com.itboye.mengwu.data.interfaces.IShopCarNext;
import com.itboye.mengwu.data.model.ShopCarBean;
import com.itboye.mengwu.data.model.ShopCarNext;
import com.itboye.mengwu.data.repository.ShopCarNextResitory;
import com.itboye.mengwu.data.repository.ShopCarResitory;

public class ShopCarNextPresenter extends BasePresenter implements
		IShopCarNext<ShopCarNext> {

	public static final String ShopCarNext_success = MainPresenter.class
			.getName() + "_ShopCarNetx_success";
	public static final String ShopCarNextFailEvent = MainPresenter.class
			.getName() + "_ShopCarNext_fail";

	public ShopCarNextPresenter(Observer observer) {
		super(observer);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void add(ShopCarNext model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(ShopCarNext model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(ShopCarNext model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void getInfo(ShopCarNext model) {
		// TODO Auto-generated method stub

		IShopCarNext<ShopCarNext> getShopCar = new ShopCarNextResitory(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "shopcar success");
						result.setEventTag(Tag_Success);
						result.setEventType(ShopCarNext_success);
						ShopCarNextPresenter.this.setChanged();
						ShopCarNextPresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "shopcar fail");
						result.setEventTag(Tag_Error);
						result.setEventType(ShopCarNextFailEvent);
						ShopCarNextPresenter.this.setChanged();
						ShopCarNextPresenter.this.notifyObservers(result);
					}
				});
		getShopCar.getInfo(model);// (model.getId());
	}

	@Override
	public List<ShopCarNext> queryYouHuiQuan(ShopCarNext model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void getShopCarXiangQing(String pid) {
		// TODO Auto-generated method stub

		IShopCarNext<ShopCarNext> getShopCar = new ShopCarNextResitory(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "shopcar success");
						result.setEventTag(Tag_Success);
						result.setEventType(ShopCarNext_success);
						ShopCarNextPresenter.this.setChanged();
						ShopCarNextPresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "shopcar fail");
						result.setEventTag(Tag_Error);
						result.setEventType(ShopCarNextFailEvent);
						ShopCarNextPresenter.this.setChanged();
						ShopCarNextPresenter.this.notifyObservers(result);
					}
				});
		getShopCar.getShopCarXiangQing(pid);// (model.getId());
	}
}
